Debug example with OpenOCD Eclipse
OpenOCD Eclipse Debug Example. The topic today I will show you how to debug a simple blink LED programme with OpenOCD eclipse. Below is a simple blink integrated LED in the board STM32F407. We firstly configure for GPIOD. Then use the method of set and reset Bits to respectively turn on and off four integrated LEDs on the Board. In my previous tutorial, OpenOCD and GBD configuration. You firstly need to disconnect your ST-Link with the chip then run OpenOCD after your OpenOCD debugger has been successfully connected with the board. You then run the GDB Hardware Debugging. One pop up will be shown and if you click on ok it will take you to the debugging window. If you want to switch back to the your normal coding window just click on icon in the top right hand corner as picture above. Now it is ready for debugging. You will see various selected icon in the toolbar. just move the cursor to these icon you will see it functionality. It could help you resume, terminate and disconnect your debug. You can step into, step over or step return to functions of your programme. In my programme, all functions are already available in library and I only take and use it for my programme. If I debug these functions I will need to step in and it will take us to other files. To make it easier, I will add an extra counter to the loop so that we can debug and observe changes from this variable. So my expectation is that counter Debug_Ctr increment one every time the programme running through the loop. Before doing the debugging I will set the breakpoint in the line of Debug_Ctr and start to run the debug programme. The debugger will run all the way through and stop at the breakpoint. If it is local variable then you can see these variables style and their value in the Variables window. Because the Debug_Ctr which I added into the programme is global variable then you have to add and monitor it in the Expressions window. Your Variables window will look like this if you step into the functions. As I said before we are not going to debug these available functions in Library but we debug the Debug_Ctr variable instead so I will add Debug_Ctr to my Expressions window. Firstly when I run the debug the debug programme will stop at the breakpoint so you see the value of Debug_Ctr is still 0. So what happen if I step over Debug_Ctr yes its value is expected to be incremented. Debug_Ctr value is now 1 as our expectation. The same if go the second loop then its value will change to 2 so it is the way to monitor value and behavior of variables in your programme. If there is any unexpected result so you will know where it come from and you will be able to fix it. OpenOCD Eclipse debug also gives a number of window option so you can monitor what is deeper happening in side your compiler. You can monitor your assembly general registers and addresses. To discover more the option you have in Eclipse OpenOCD debugger you can go to Window => Show viewer then you can add any monitoring window that you need for your debugging working. Ok So I end my debugging example here and will come shortly for other topics. Reference: http://www.emprog.com/support/documentation/thunderbench-debugger-guide.pdf